﻿




using System.Collections.Generic;
using Hotpot.Infrastructure;

namespace Hotpot.Skinning
{
    public class HotpotSkinResolver : ISkinResolver
    {
        private readonly HotpotContext context;

        public HotpotSkinResolver(HotpotContext context)
        {
            this.context = context;
        }

        #region ISkinResolver Members

        public void Resolve(SkinResolverContext skinResolverContext, IList<string> skinPaths)
        {
            string skinsPath = "~" + context.Site.SkinsPath;
            string[] skinNames = skinResolverContext.Skin.Split('/');
            string skinPath = string.Format("{0}/{1}", skinsPath, skinNames[0]);

            skinPaths.Add(skinPath);

            if (skinNames.Length > 1)
                for (int i = 1; i < skinNames.Length; i++)
                    skinPaths.Add(skinPath = string.Format("{0}/Layers/{1}", skinPath, skinNames[i]));
        }

        #endregion
    }
}
